package org.hgvc.webapp.ets.jsf.beans.agent;

import java.util.List;

import org.hgvc.webapp.ets.bo.DocSubmission;
import org.hgvc.webapp.ets.bo.Member;
import org.hgvc.webapp.ets.bo.MemberComp;
import org.hgvc.webapp.ets.bo.MemberInd;
import org.hgvc.webapp.ets.constant.CommonConstant;
import org.hgvc.webapp.ets.constant.MemberConstant;
import org.hgvc.webapp.ets.spring.service.MemberService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;



public class AgentProspectDocCheckListBean extends AbstractBean {

	public static final String BEAN_NAME="agentProspectDocCheckListBean";
	public static final String NAV_CHECK_IND_ACTION="agentProspectIndDocCheckList";
	public static final String NAV_CHECK_COMP_ACTION="agentProspectCompDocCheckList";
	private Member member;
	private MemberComp memberComp;
	private MemberInd memberInd;
	private MemberService service;
	private List<DocSubmission> mandList;
	private List<DocSubmission> notmandList;
	public Member getMember() {
		return member;
	}
	public void setMember(Member member) {
		this.member = member;
	}
	public MemberComp getMemberComp() {
		return memberComp;
	}
	public void setMemberComp(MemberComp memberComp) {
		this.memberComp = memberComp;
	}
	public MemberInd getMemberInd() {
		return memberInd;
	}
	public void setMemberInd(MemberInd memberInd) {
		this.memberInd = memberInd;
	}
	public List<DocSubmission> getMandList() {
		return mandList;
	}
	public void setMandList(List<DocSubmission> mandList) {
		this.mandList = mandList;
	}
	public List<DocSubmission> getNotmandList() {
		return notmandList;
	}
	public void setNotmandList(List<DocSubmission> notmandList) {
		this.notmandList = notmandList;
	}
	public void setService(MemberService service) {
		this.service = service;
	}

	/*----------------------------------------------------------*/
	public String navCheckListAction(Member member){
		try{

			this.member = member;
			mandList = service.getMemberDocSubmissionList(member.getMemberId(), MemberConstant.MEMBER_DOC_MANDATORY);
			notmandList = service.getMemberDocSubmissionList(member.getMemberId(), MemberConstant.MEMBER_DOC_NOT_MANDATORY);
			if(member.getMemberType().equalsIgnoreCase(CommonConstant.MEMBER_TYPE_COMP)){
				memberComp = service.getMemberCompByMemberId(member.getMemberId());
				return NAV_CHECK_COMP_ACTION;
			}else{
				memberInd = service.getMemberIndByMemberId(member.getMemberId());
				return NAV_CHECK_IND_ACTION;
			}
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return null;
	}

	public String completeCheckAction(){
		try{
			service.completeCheckMemberDoc(member, mandList, notmandList, getThisUser());
			return AgentProspectMagmtBean.NAV_LIST;
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}

		return null;
	}

	public String checkAction(){
		try{
			service.checkMemberDoc(member, mandList, notmandList, getThisUser());
			return AgentProspectMagmtBean.NAV_LIST;
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return null;
	}

	public String backAction(){
		return AgentProspectMagmtBean.NAV_LIST;
	}
}
